// tge.rs
// copyright zipxing@hotmail.com 2022~2023

use crate::{
    render::{buffer::Buffer, sprite::Sprites},
    util::Rect,
};
use crossterm::event::Event;
use std::time::Duration;

pub trait Adapter {
    fn init(&mut self, w: u16, h: u16, rx: f32, ry: f32, s: String);
    fn reset(&mut self);
    fn poll_event(&mut self, timeout: Duration, ev: &mut Vec<Event>) -> bool;
    fn render_buffer(
        &mut self,
        cb: &Buffer,
        pb: &Buffer,
        ps: &mut Sprites,
        stage: u32,
    ) -> Result<(), String>;
    fn size(&self) -> Rect;
    fn cell_width(&self) -> f32;
    fn cell_height(&self) -> f32;
    fn hide_cursor(&mut self) -> Result<(), String>;
    fn show_cursor(&mut self) -> Result<(), String>;
    fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), String>;
    fn get_cursor(&mut self) -> Result<(u16, u16), String>;
}

/// sdl底层驱动
pub mod sdl;

/// crossterm底层驱动
pub mod cross;
